<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title></title>
</head>

<body>
  <div id="app">
    <h1>父组件：{{num}}</h1>
    <!--调用 父组件中绑定子组件中定义的自定义事件 -->
    <Child @myincr="myincr"></Child>

  </div>

  <script id="child" type="text/x-template">
    <div>
      <h1>子组件：{{num}}</h1>
      <hr>
      <button @click="bbb">子组件自增</button>
    </div>
  </script>
  <script src="./js/vue.js"></script>
  <script>
    
       const Child = {
           template:'#child',
           data(){
               return {num:100}
           },
           methods:{
               bbb(){
                   this.num ++
                   this.$emit('myincr', 2)
               }
           }
       }



       const app = new Vue({
           el:"#app",
           data:{
               num : 250
           },
           components :{Child},
           methods:{
            myincr(a){
                this.num += a 
            }
           }


       })
   
  </script>
</body>

</html>